package enumandlambda;

/**
 * @author shkstart
 * 使用interruprt
 * @create 2022-12-01-12:49
 */
public class ThreadInterrupet2 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
//            while (!Thread.interrupted()) {
            while(!Thread.currentThread().isInterrupted()){
                System.out.println("正在转账。。。。");
            }
            System.out.println("险些误 了大事");


        });
        //启动线程
        thread.start();
        Thread.sleep(100);
//        终止线程
        thread.interrupt();
        System.out.println("有内鬼，终止交易");
    }
}
